/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Seguridad.Vistas;
import Seguridad.Controlador.Validacion;
import Seguridad.Controlador.controladorseguridad;
import java.util.Date;
import modelos.Usuario;
import modelos.Rol;
import modelos.Vista;
import modelos.Vistaxrol;
import modelos.VistaxrolId;
import javax.swing.JOptionPane;

/**
 *
 * @author Saori
 */
public class RolNuevo extends javax.swing.JInternalFrame {

    /**
     * Creates new form RolNuevo
     */
    
    public static Usuario usuario = lbj.LBJ.Login.usuario;
    public static RolBuscar buscarrol;
    public static controladorseguridad mycontroladorseguridad = new controladorseguridad();
    public static Validacion validacion = new Validacion();
    
    public RolNuevo() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        btnGuardar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDescripcionRol = new javax.swing.JTextArea();
        txtNombreRol = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        chkVentas = new javax.swing.JCheckBox();
        chkClientes = new javax.swing.JCheckBox();
        chkProveedores = new javax.swing.JCheckBox();
        chkCompras = new javax.swing.JCheckBox();
        chkProductos = new javax.swing.JCheckBox();
        chkMovimientos = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        chkUsuarios = new javax.swing.JCheckBox();
        chkRoles = new javax.swing.JCheckBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        chkOrden = new javax.swing.JCheckBox();
        chkEmpleados = new javax.swing.JCheckBox();
        chkMaquinas = new javax.swing.JCheckBox();
        chkAsignaciones = new javax.swing.JCheckBox();
        chkRVentas = new javax.swing.JCheckBox();
        chkCalcularStock = new javax.swing.JCheckBox();
        chkKardex = new javax.swing.JCheckBox();
        chkInventario = new javax.swing.JCheckBox();
        chkRMovimientos = new javax.swing.JCheckBox();
        chkStockMin = new javax.swing.JCheckBox();
        chkActividades = new javax.swing.JCheckBox();
        chkReceta = new javax.swing.JCheckBox();
        chkRGalleta = new javax.swing.JCheckBox();
        chkLogs = new javax.swing.JCheckBox();
        chkAlgoritmos = new javax.swing.JCheckBox();
        chkRObrero = new javax.swing.JCheckBox();
        chkRActividad = new javax.swing.JCheckBox();
        chkRAsignacion = new javax.swing.JCheckBox();
        btnSeleccionar = new javax.swing.JButton();
        chkProducciones = new javax.swing.JCheckBox();
        chkRCompras = new javax.swing.JCheckBox();
        btnCancelar = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setTitle("Registrar Rol");

        btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/save.png"))); // NOI18N
        btnGuardar.setPreferredSize(new java.awt.Dimension(45, 45));
        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGuardarActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Generales"));

        jLabel1.setText("Nombre de Rol:");

        jLabel2.setText("Descripción:");

        txtDescripcionRol.setColumns(20);
        txtDescripcionRol.setRows(5);
        jScrollPane1.setViewportView(txtDescripcionRol);

        txtNombreRol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNombreRolActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel1)
                    .add(jLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(txtNombreRol, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 166, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(68, 68, 68))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(22, 22, 22)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(txtNombreRol, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Permisos"));
        jPanel2.setLayout(new java.awt.GridBagLayout());

        chkVentas.setText("Ventas");
        chkVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkVentasActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(23, 18, 0, 0);
        jPanel2.add(chkVentas, gridBagConstraints);

        chkClientes.setText("Clientes");
        chkClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkClientesActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(23, 27, 0, 0);
        jPanel2.add(chkClientes, gridBagConstraints);

        chkProveedores.setText("Proveedores");
        chkProveedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkProveedoresActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkProveedores, gridBagConstraints);

        chkCompras.setText("Compras");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkCompras, gridBagConstraints);

        chkProductos.setText("Productos");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkProductos, gridBagConstraints);

        chkMovimientos.setText("Movimientos");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkMovimientos, gridBagConstraints);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("VENTAS: ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(27, 16, 0, 0);
        jPanel2.add(jLabel3, gridBagConstraints);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("COMPRAS:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(7, 16, 0, 0);
        jPanel2.add(jLabel4, gridBagConstraints);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("ALMACÉN:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(7, 16, 0, 0);
        jPanel2.add(jLabel5, gridBagConstraints);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("SEGURIDAD:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(7, 16, 0, 0);
        jPanel2.add(jLabel6, gridBagConstraints);

        chkUsuarios.setText("Usuarios");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkUsuarios, gridBagConstraints);

        chkRoles.setText("Roles");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkRoles, gridBagConstraints);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("CONFIGURACIÓN:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(7, 16, 0, 0);
        jPanel2.add(jLabel7, gridBagConstraints);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("PRODUCCIÓN:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(7, 16, 0, 0);
        jPanel2.add(jLabel8, gridBagConstraints);

        chkOrden.setText("Orden de Producción");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkOrden, gridBagConstraints);

        chkEmpleados.setText("Empleados");
        chkEmpleados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkEmpleadosActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkEmpleados, gridBagConstraints);

        chkMaquinas.setText("Máquinas");
        chkMaquinas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkMaquinasActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkMaquinas, gridBagConstraints);

        chkAsignaciones.setText("Asignaciones");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkAsignaciones, gridBagConstraints);

        chkRVentas.setText("Reporte Ventas");
        chkRVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRVentasActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(23, 11, 0, 0);
        jPanel2.add(chkRVentas, gridBagConstraints);

        chkCalcularStock.setText("Calcular Stock");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkCalcularStock, gridBagConstraints);

        chkKardex.setText("Kardex");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkKardex, gridBagConstraints);

        chkInventario.setText("Inventario");
        chkInventario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkInventarioActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 27;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 2, 0, 0);
        jPanel2.add(chkInventario, gridBagConstraints);

        chkRMovimientos.setText("Reporte Movimientos");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkRMovimientos, gridBagConstraints);

        chkStockMin.setText("Stock Mínimo");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkStockMin, gridBagConstraints);

        chkActividades.setText("Actividades");
        chkActividades.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkActividadesActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkActividades, gridBagConstraints);

        chkReceta.setText("Receta");
        chkReceta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRecetaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 27;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 2, 0, 0);
        jPanel2.add(chkReceta, gridBagConstraints);

        chkRGalleta.setText("Reporte Producción Galleta");
        chkRGalleta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRGalletaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 18, 0, 0);
        jPanel2.add(chkRGalleta, gridBagConstraints);

        chkLogs.setText("Logs");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkLogs, gridBagConstraints);

        chkAlgoritmos.setText("Algoritmos");
        chkAlgoritmos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkAlgoritmosActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 27;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 2, 0, 0);
        jPanel2.add(chkAlgoritmos, gridBagConstraints);

        chkRObrero.setText("Reporte Producción Obrero");
        chkRObrero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRObreroActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 12;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.gridwidth = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 27, 0, 0);
        jPanel2.add(chkRObrero, gridBagConstraints);

        chkRActividad.setText("Reporte Producción Actividad");
        chkRActividad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRActividadActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.gridwidth = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkRActividad, gridBagConstraints);

        chkRAsignacion.setText("Reporte Asignación");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 27;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 2, 0, 0);
        jPanel2.add(chkRAsignacion, gridBagConstraints);

        btnSeleccionar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnSeleccionar.setText("Seleccionar Todos");
        btnSeleccionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSeleccionarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 27;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(8, 2, 7, 6);
        jPanel2.add(btnSeleccionar, gridBagConstraints);

        chkProducciones.setText("Producciones");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkProducciones, gridBagConstraints);

        chkRCompras.setText("Reporte Compras");
        chkRCompras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkRComprasActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 19;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 7;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(3, 11, 0, 0);
        jPanel2.add(chkRCompras, gridBagConstraints);

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/error 1.png"))); // NOI18N
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        jLabel10.setText("Guardar");

        jLabel11.setText("Cancelar");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(44, 44, 44)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .add(layout.createSequentialGroup()
                        .add(323, 323, 323)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(btnGuardar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel10))
                        .add(98, 98, 98)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel11)
                            .add(btnCancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .add(43, 43, 43))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(17, 17, 17)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 178, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(btnGuardar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(btnCancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel11)
                    .add(jLabel10))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed
        // TODO add your handling code here:
        if(validacion.es_vacio(txtNombreRol.getText()) && validacion.es_vacio(txtDescripcionRol.getText()))
            JOptionPane.showMessageDialog(null, validacion.msj + "Nombre de Rol y Descripción");
        else if(validacion.es_vacio(txtNombreRol.getText()))
            JOptionPane.showMessageDialog(null, validacion.msj + "Nombre de Rol");
        else if(!validacion.es_nombre(txtNombreRol.getText()))
            JOptionPane.showMessageDialog(null, "Nombre de Rol debe contener: " + validacion.msj);
        else if(mycontroladorseguridad.getRolByNombre(txtNombreRol.getText()) != null)
            JOptionPane.showMessageDialog(null, "El nombre de Rol ya se encuentra en uso. Ingrese otro nombre de Rol.");
        else if(validacion.es_vacio(txtDescripcionRol.getText()))
            JOptionPane.showMessageDialog(null, validacion.msj + "Descripción");
        else if(!validacion.es_descripcion(txtDescripcionRol.getText()))
            JOptionPane.showMessageDialog(null, "Descripción debe contener: " + validacion.msj);
        else if(!(chkVentas.isSelected() || chkClientes.isSelected() || chkRVentas.isSelected() || 
                chkCompras.isSelected() || chkProveedores.isSelected() || chkRCompras.isSelected() || 
                chkProductos.isSelected() || chkMovimientos.isSelected() || 
                chkCalcularStock.isSelected() || 
                chkInventario.isSelected() || chkKardex.isSelected() || 
                chkRMovimientos.isSelected() || chkStockMin.isSelected() ||
                chkReceta.isSelected() ||  
                chkEmpleados.isSelected() || chkMaquinas.isSelected() || 
                chkActividades.isSelected() || chkAlgoritmos.isSelected() || 
                chkOrden.isSelected() || chkAsignaciones.isSelected() || chkProducciones.isSelected() || 
                chkRGalleta.isSelected() || chkRObrero.isSelected() || chkRActividad.isSelected() ||
                chkRAsignacion.isSelected() ||
                chkUsuarios.isSelected() || chkRoles.isSelected() || 
                chkLogs.isSelected()))
        {
            JOptionPane.showMessageDialog(null, "Debe seleccionar al menos uno de los privilegios de acceso.");
        }
        else{
            Rol rol=mycontroladorseguridad.insertarrol(txtNombreRol.getText(),txtDescripcionRol.getText());

            mycontroladorseguridad.insertarlog(usuario, new Date(), "Insertar", "Rol", "Registrar Rol");

            //MENU VENTAS
            if(chkVentas.isSelected()){//Menu Ventas
                mycontroladorseguridad.insertarvistaxrol(rol,1,"Ventas");
            }
            if(chkClientes.isSelected()){//Menu Ventas
                mycontroladorseguridad.insertarvistaxrol(rol,2,"Clientes");
            }
            if(chkRVentas.isSelected()){//Menu Ventas
                mycontroladorseguridad.insertarvistaxrol(rol,3,"Reporte Ventas");
            }
//            if(chkRClientes.isSelected()){//Menu Ventas
//                mycontroladorseguridad.insertarvistaxrol(rol,4,"Reporte Clientes");
//            }
            //MENU COMPRAS
            if(chkCompras.isSelected()){// Menu Compras
                mycontroladorseguridad.insertarvistaxrol(rol,5,"Compras");
            }
            if(chkProveedores.isSelected()){//Menu Compras
                mycontroladorseguridad.insertarvistaxrol(rol,6,"Proveedores");
            }
            if(chkRCompras.isSelected()){// Menu Compras
                mycontroladorseguridad.insertarvistaxrol(rol,31,"Reporte Compras");
            }
            //MENU ALMACÉN
            if(chkProductos.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,7,"Productos");
            }
            if(chkMovimientos.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,8,"Movimientos");
            }
//            if(chkAlmacenes.isSelected()){//Menu Almacén
//                mycontroladorseguridad.insertarvistaxrol(rol,9,"Almacenes");
//            } 
            if(chkCalcularStock.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,10,"Calcular Stock");
            } 
            if(chkInventario.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,11,"Inventario");
            } 
            if(chkKardex.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,12,"Reporte Kardex");
            }
            if(chkRMovimientos.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,13,"Reporte Movimientos");
            } 
            if(chkStockMin.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,14,"Reporte Stock Minimo");
            } 
            if(chkReceta.isSelected()){//Menu Almacén
                mycontroladorseguridad.insertarvistaxrol(rol,15,"Reporte Receta");
            } 
            //MENU CONFIGURACIÓN
            if(chkEmpleados.isSelected()){//Menu Configuración
                mycontroladorseguridad.insertarvistaxrol(rol,16,"Empleados");
            } 
            if(chkMaquinas.isSelected()){//Menu Configuración
                mycontroladorseguridad.insertarvistaxrol(rol,17,"Maquinas");
            } 
            if(chkActividades.isSelected()){//Menu Configuración
                mycontroladorseguridad.insertarvistaxrol(rol,18,"Actividades");
            } 
            if(chkAlgoritmos.isSelected()){//Menu Configuración
                mycontroladorseguridad.insertarvistaxrol(rol,19,"Algoritmos");
            } 
            //MENU PRODUCCIÓN
            if(chkOrden.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,20,"Orden de Produccion");
            } 
            if(chkAsignaciones.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,21,"Asignaciones");
            } 
            if(chkProducciones.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,30,"Producciones");
            } 
            if(chkRGalleta.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,22,"Reporte Produccion Galleta");
            } 
            if(chkRObrero.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,23,"Reporte Produccion Obrero");
            } 
            if(chkRActividad.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,24,"Reporte Produccion Actividad");
            } 
            if(chkRAsignacion.isSelected()){//Menu Producción
                mycontroladorseguridad.insertarvistaxrol(rol,29,"Reporte Asignacion");
            } 
            //MENU SEGURIDAD
            if(chkUsuarios.isSelected()){//Menu Seguridad
                mycontroladorseguridad.insertarvistaxrol(rol,25,"Usuarios");
            } 
            if(chkRoles.isSelected()){//Menu Seguridad
                mycontroladorseguridad.insertarvistaxrol(rol,26,"Roles");
            } 
            if(chkLogs.isSelected()){//Menu Seguridad
                mycontroladorseguridad.insertarvistaxrol(rol,27,"Logs");
            } 
//            if(chkContrasena.isSelected()){//Menu Seguridad
//                mycontroladorseguridad.insertarvistaxrol(rol,28,"Modificar Contrasena");
//            } 

            JOptionPane.showMessageDialog(null, "El rol se registró existosamente.");
            mycontroladorseguridad.insertarlog(usuario, new Date(), "Insertar", "Vistaxrol", "Registrar Vistaxrol");
            
            lbj.LBJ.Login.escritorio.rol.refreshRolTable();
            this.dispose();
        }
        
    }//GEN-LAST:event_btnGuardarActionPerformed

    private void chkVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkVentasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkVentasActionPerformed

    private void chkClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkClientesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkClientesActionPerformed

    private void chkEmpleadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkEmpleadosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkEmpleadosActionPerformed

    private void chkMaquinasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkMaquinasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkMaquinasActionPerformed

    private void chkRVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRVentasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRVentasActionPerformed

    private void chkInventarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkInventarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkInventarioActionPerformed

    private void chkActividadesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkActividadesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkActividadesActionPerformed

    private void chkRecetaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRecetaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRecetaActionPerformed

    private void txtNombreRolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNombreRolActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNombreRolActionPerformed

    private void chkRGalletaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRGalletaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRGalletaActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "¿Está seguro de cancelar el registro?",
                "Mensaje",JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
            lbj.LBJ.Login.escritorio.rol.refreshRolTable();
            this.dispose();
        }
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void chkProveedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkProveedoresActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkProveedoresActionPerformed

    private void chkAlgoritmosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAlgoritmosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkAlgoritmosActionPerformed

    private void chkRObreroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRObreroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRObreroActionPerformed

    private void chkRActividadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRActividadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRActividadActionPerformed

    private void btnSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeleccionarActionPerformed
        // TODO add your handling code here:
        chkVentas.setSelected(true);
        chkClientes.setSelected(true);
        chkRVentas.setSelected(true);
//        chkRClientes.setSelected(true);
        chkCompras.setSelected(true);
        chkProveedores.setSelected(true);
        chkProductos.setSelected(true);
        chkMovimientos.setSelected(true);
//        chkAlmacenes.setSelected(true);
        chkCalcularStock.setSelected(true);
        chkInventario.setSelected(true);
        chkKardex.setSelected(true);
        chkRMovimientos.setSelected(true);
        chkStockMin.setSelected(true);
        chkReceta.setSelected(true);
        chkEmpleados.setSelected(true);
        chkMaquinas.setSelected(true);
        chkActividades.setSelected(true);
        chkAlgoritmos.setSelected(true);
        chkOrden.setSelected(true);
        chkAsignaciones.setSelected(true);
        chkRGalleta.setSelected(true);
        chkRObrero.setSelected(true);
        chkRActividad.setSelected(true);
        chkUsuarios.setSelected(true);
        chkRoles.setSelected(true);
        chkLogs.setSelected(true);
//        chkContrasena.setSelected(true);
        chkRAsignacion.setSelected(true);
        chkProducciones.setSelected(true);
        chkRCompras.setSelected(true);
    }//GEN-LAST:event_btnSeleccionarActionPerformed

    private void chkRComprasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkRComprasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chkRComprasActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnGuardar;
    private javax.swing.JButton btnSeleccionar;
    private javax.swing.JCheckBox chkActividades;
    private javax.swing.JCheckBox chkAlgoritmos;
    private javax.swing.JCheckBox chkAsignaciones;
    private javax.swing.JCheckBox chkCalcularStock;
    private javax.swing.JCheckBox chkClientes;
    private javax.swing.JCheckBox chkCompras;
    private javax.swing.JCheckBox chkEmpleados;
    private javax.swing.JCheckBox chkInventario;
    private javax.swing.JCheckBox chkKardex;
    private javax.swing.JCheckBox chkLogs;
    private javax.swing.JCheckBox chkMaquinas;
    private javax.swing.JCheckBox chkMovimientos;
    private javax.swing.JCheckBox chkOrden;
    private javax.swing.JCheckBox chkProducciones;
    private javax.swing.JCheckBox chkProductos;
    private javax.swing.JCheckBox chkProveedores;
    private javax.swing.JCheckBox chkRActividad;
    private javax.swing.JCheckBox chkRAsignacion;
    private javax.swing.JCheckBox chkRCompras;
    private javax.swing.JCheckBox chkRGalleta;
    private javax.swing.JCheckBox chkRMovimientos;
    private javax.swing.JCheckBox chkRObrero;
    private javax.swing.JCheckBox chkRVentas;
    private javax.swing.JCheckBox chkReceta;
    private javax.swing.JCheckBox chkRoles;
    private javax.swing.JCheckBox chkStockMin;
    private javax.swing.JCheckBox chkUsuarios;
    private javax.swing.JCheckBox chkVentas;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea txtDescripcionRol;
    private javax.swing.JTextField txtNombreRol;
    // End of variables declaration//GEN-END:variables
}
